from pathlib import Path

def count_common_words(filename, word):
    path = Path(filename)

    try:
        contents = path.read_text(encoding='utf-8')
    except FileNotFoundError:
        pass
    else:
        words_count = contents.lower().count(word)  #count()用来确定特定单词
                                                    #或短语在字符串中的出现次数
                                                    
        print(f"'{word}' appears in {filename} about {words_count} times.")

count_common_words('day16/alice.txt','alice')